home *** CD-ROM | disk | FTP | other *** search
/ Erotic Games: Memory / Erotic Games: Memory.iso / mac / air_installers / AdobeAIR.exe / setup.swf / scripts / mx / controls / ProgressBar.as < prev    next >
Text File  |  2009-02-12  |  29KB  |  867 lines

  1. package mx.controls
  2. {
  3.    import flash.display.DisplayObject;
  4.    import flash.display.Graphics;
  5.    import flash.events.Event;
  6.    import flash.events.IEventDispatcher;
  7.    import flash.events.ProgressEvent;
  8.    import flash.events.TimerEvent;
  9.    import flash.text.TextLineMetrics;
  10.    import flash.utils.Timer;
  11.    import mx.core.FlexVersion;
  12.    import mx.core.IFlexDisplayObject;
  13.    import mx.core.IFlexModuleFactory;
  14.    import mx.core.IFontContextComponent;
  15.    import mx.core.IUITextField;
  16.    import mx.core.UIComponent;
  17.    import mx.core.UITextField;
  18.    import mx.core.mx_internal;
  19.    import mx.styles.ISimpleStyleClient;
  20.    
  21.    use namespace mx_internal;
  22.    
  23.    public class ProgressBar extends UIComponent implements IFontContextComponent
  24.    {
  25.       
  26.       mx_internal static const VERSION:String = "3.0.0.0";
  27.        
  28.       
  29.       private var _direction:String = "right";
  30.       
  31.       private var stopPolledMode:Boolean = false;
  32.       
  33.       mx_internal var _labelField:IUITextField;
  34.       
  35.       mx_internal var _determinateBar:IFlexDisplayObject;
  36.       
  37.       private var sourceChanged:Boolean = false;
  38.       
  39.       private var _interval:Number = 30;
  40.       
  41.       private var trackSkinChanged:Boolean = false;
  42.       
  43.       mx_internal var _content:UIComponent;
  44.       
  45.       private var _source:Object;
  46.       
  47.       mx_internal var _track:IFlexDisplayObject;
  48.       
  49.       mx_internal var _bar:UIComponent;
  50.       
  51.       mx_internal var _barMask:IFlexDisplayObject;
  52.       
  53.       private var barSkinChanged:Boolean = false;
  54.       
  55.       private var _stringSource:String;
  56.       
  57.       private var _labelPlacement:String = "bottom";
  58.       
  59.       private var _value:Number = 0;
  60.       
  61.       private var indeterminateChanged:Boolean = true;
  62.       
  63.       private var _mode:String = "event";
  64.       
  65.       private var stringSourceChanged:Boolean = false;
  66.       
  67.       private var modeChanged:Boolean = false;
  68.       
  69.       private var _conversion:Number = 1;
  70.       
  71.       mx_internal var _indeterminateBar:IFlexDisplayObject;
  72.       
  73.       private var indeterminateSkinChanged:Boolean = false;
  74.       
  75.       private var _indeterminate:Boolean = false;
  76.       
  77.       private var pollTimer:Timer;
  78.       
  79.       private var _minimum:Number = 0;
  80.       
  81.       private var labelOverride:String;
  82.       
  83.       private var _maximum:Number = 0;
  84.       
  85.       private var visibleChanged:Boolean = false;
  86.       
  87.       private var indeterminatePlaying:Boolean = false;
  88.       
  89.       private var _label:String;
  90.       
  91.       public function ProgressBar()
  92.       {
  93.          super();
  94.          pollTimer = new Timer(_interval);
  95.          cacheAsBitmap = true;
  96.       }
  97.       
  98.       [Bindable("minimumChanged")]
  99.       public function get minimum() : Number
  100.       {
  101.          return _minimum;
  102.       }
  103.       
  104.       [Bindable("conversionChanged")]
  105.       public function get conversion() : Number
  106.       {
  107.          return _conversion;
  108.       }
  109.       
  110.       private function completeHandler(param1:Event) : void
  111.       {
  112.          dispatchEvent(param1);
  113.          invalidateDisplayList();
  114.       }
  115.       
  116.       [Bindable("sourceChanged")]
  117.       public function get source() : Object
  118.       {
  119.          return _source;
  120.       }
  121.       
  122.       public function set minimum(param1:Number) : void
  123.       {
  124.          if(!isNaN(param1) && _mode == ProgressBarMode.MANUAL && param1 != _minimum)
  125.          {
  126.             _minimum = param1;
  127.             invalidateDisplayList();
  128.             dispatchEvent(new Event("minimumChanged"));
  129.          }
  130.       }
  131.       
  132.       [Bindable("maximumChanged")]
  133.       public function get maximum() : Number
  134.       {
  135.          return _maximum;
  136.       }
  137.       
  138.       override protected function createChildren() : void
  139.       {
  140.          var _loc1_:Class = null;
  141.          super.createChildren();
  142.          if(!mx_internal::_content)
  143.          {
  144.             _content = new UIComponent();
  145.             addChild(mx_internal::_content);
  146.          }
  147.          if(!mx_internal::_bar)
  148.          {
  149.             _bar = new UIComponent();
  150.             mx_internal::_content.addChild(mx_internal::_bar);
  151.          }
  152.          if(!mx_internal::_barMask)
  153.          {
  154.             if(FlexVersion.compatibilityVersion >= FlexVersion.VERSION_3_0)
  155.             {
  156.                _loc1_ = getStyle("maskSkin");
  157.                _barMask = new _loc1_();
  158.             }
  159.             else
  160.             {
  161.                _barMask = new UIComponent();
  162.             }
  163.             mx_internal::_barMask.visible = true;
  164.             mx_internal::_bar.addChild(DisplayObject(mx_internal::_barMask));
  165.             UIComponent(mx_internal::_bar).mask = DisplayObject(mx_internal::_barMask);
  166.          }
  167.          if(!mx_internal::_labelField)
  168.          {
  169.             _labelField = IUITextField(createInFontContext(UITextField));
  170.             mx_internal::_labelField.styleName = this;
  171.             addChild(DisplayObject(mx_internal::_labelField));
  172.          }
  173.       }
  174.       
  175.       public function set source(param1:Object) : void
  176.       {
  177.          var value:Object = param1;
  178.          if(value is String)
  179.          {
  180.             _stringSource = String(value);
  181.             try
  182.             {
  183.                value = document[_stringSource];
  184.             }
  185.             catch(e:Error)
  186.             {
  187.                stringSourceChanged = true;
  188.             }
  189.          }
  190.          if(value)
  191.          {
  192.             _source = value;
  193.             sourceChanged = true;
  194.             modeChanged = true;
  195.             indeterminateChanged = true;
  196.             invalidateProperties();
  197.             invalidateDisplayList();
  198.          }
  199.          else if(_source != null)
  200.          {
  201.             _source = null;
  202.             sourceChanged = true;
  203.             indeterminateChanged = true;
  204.             invalidateProperties();
  205.             invalidateDisplayList();
  206.             pollTimer.reset();
  207.          }
  208.       }
  209.       
  210.       public function set conversion(param1:Number) : void
  211.       {
  212.          if(!isNaN(param1) && Number(param1) > 0 && param1 != _conversion)
  213.          {
  214.             _conversion = Number(param1);
  215.             invalidateDisplayList();
  216.             dispatchEvent(new Event("conversionChanged"));
  217.          }
  218.       }
  219.       
  220.       public function set maximum(param1:Number) : void
  221.       {
  222.          if(!isNaN(param1) && _mode == ProgressBarMode.MANUAL && param1 != _maximum)
  223.          {
  224.             _maximum = param1;
  225.             invalidateDisplayList();
  226.             dispatchEvent(new Event("maximumChanged"));
  227.          }
  228.       }
  229.       
  230.       public function set mode(param1:String) : void
  231.       {
  232.          if(param1 != _mode)
  233.          {
  234.             if(_mode == ProgressBarMode.POLLED)
  235.             {
  236.                stopPolledMode = true;
  237.             }
  238.             _mode = param1;
  239.             modeChanged = true;
  240.             indeterminateChanged = true;
  241.             invalidateProperties();
  242.             invalidateDisplayList();
  243.          }
  244.       }
  245.       
  246.       private function stopPlayingIndeterminate() : void
  247.       {
  248.          if(indeterminatePlaying)
  249.          {
  250.             indeterminatePlaying = false;
  251.             pollTimer.removeEventListener(TimerEvent.TIMER,updateIndeterminateHandler);
  252.             if(_mode != ProgressBarMode.POLLED)
  253.             {
  254.                pollTimer.reset();
  255.             }
  256.          }
  257.       }
  258.       
  259.       [Bindable("labelPlacementChanged")]
  260.       public function get labelPlacement() : String
  261.       {
  262.          return _labelPlacement;
  263.       }
  264.       
  265.       private function progressHandler(param1:ProgressEvent) : void
  266.       {
  267.          _setProgress(param1.bytesLoaded,param1.bytesTotal);
  268.       }
  269.       
  270.       override protected function measure() : void
  271.       {
  272.          var _loc1_:Number = NaN;
  273.          var _loc2_:Number = NaN;
  274.          super.measure();
  275.          var _loc3_:Number = NaN;
  276.          var _loc4_:Number = NaN;
  277.          var _loc5_:Number = getStyle("trackHeight");
  278.          var _loc6_:Number = mx_internal::_track.measuredWidth;
  279.          var _loc7_:Number = !!isNaN(_loc5_) ? Number(mx_internal::_track.measuredHeight) : Number(_loc5_);
  280.          var _loc8_:Number = getStyle("horizontalGap");
  281.          var _loc9_:Number = getStyle("verticalGap");
  282.          var _loc10_:Number = getStyle("paddingLeft");
  283.          var _loc11_:Number = getStyle("paddingRight");
  284.          var _loc12_:Number = getStyle("paddingTop");
  285.          var _loc13_:Number = getStyle("paddingBottom");
  286.          var _loc14_:Number = getStyle("labelWidth");
  287.          var _loc15_:TextLineMetrics = measureText(predictLabelText());
  288.          var _loc16_:Number = !!isNaN(_loc14_) ? Number(_loc15_.width + UITextField.TEXT_WIDTH_PADDING) : Number(_loc14_);
  289.          var _loc17_:Number = _loc15_.height + UITextField.TEXT_HEIGHT_PADDING;
  290.          switch(labelPlacement)
  291.          {
  292.             case ProgressBarLabelPlacement.LEFT:
  293.             case ProgressBarLabelPlacement.RIGHT:
  294.                _loc1_ = _loc16_ + _loc6_ + _loc10_ + _loc11_ + _loc8_;
  295.                _loc2_ = Math.max(_loc17_,_loc7_) + _loc12_ + _loc13_;
  296.                measuredMinWidth = _loc1_;
  297.                break;
  298.             case ProgressBarLabelPlacement.CENTER:
  299.                _loc1_ = Math.max(_loc16_,_loc6_) + _loc10_ + _loc11_ + _loc8_;
  300.                _loc2_ = Math.max(_loc17_,_loc7_) + _loc12_ + _loc13_;
  301.                measuredMinWidth = _loc16_;
  302.                break;
  303.             default:
  304.                _loc1_ = Math.max(_loc16_,_loc6_) + _loc10_ + _loc11_;
  305.                _loc2_ = _loc17_ + _loc7_ + _loc12_ + _loc13_ + _loc9_;
  306.                measuredMinWidth = _loc16_;
  307.          }
  308.          measuredWidth = _loc1_;
  309.          measuredMinHeight = measuredHeight = _loc2_;
  310.          if(!isNaN(_loc3_))
  311.          {
  312.             measuredMinWidth = _loc3_;
  313.          }
  314.          if(!isNaN(_loc4_))
  315.          {
  316.             measuredMinHeight = _loc4_;
  317.          }
  318.       }
  319.       
  320.       public function get fontContext() : IFlexModuleFactory
  321.       {
  322.          return moduleFactory;
  323.       }
  324.       
  325.       private function predictLabelText() : String
  326.       {
  327.          var _loc2_:Number = NaN;
  328.          if(label == null)
  329.          {
  330.             return "";
  331.          }
  332.          var _loc1_:String = label;
  333.          if(_maximum != 0)
  334.          {
  335.             _loc2_ = _maximum;
  336.          }
  337.          else
  338.          {
  339.             _loc2_ = 100000;
  340.          }
  341.          if(_loc1_)
  342.          {
  343.             if(_indeterminate)
  344.             {
  345.                _loc1_ = _loc1_.replace("%1",String(Math.floor(_loc2_ / _conversion)));
  346.                _loc1_ = _loc1_.replace("%2","??");
  347.                _loc1_ = _loc1_.replace("%3","");
  348.                _loc1_ = _loc1_.replace("%%","");
  349.             }
  350.             else
  351.             {
  352.                _loc1_ = _loc1_.replace("%1",String(Math.floor(_loc2_ / _conversion)));
  353.                _loc1_ = _loc1_.replace("%2",String(Math.floor(_loc2_ / _conversion)));
  354.                _loc1_ = _loc1_.replace("%3","100");
  355.                _loc1_ = _loc1_.replace("%%","%");
  356.             }
  357.          }
  358.          var _loc3_:String = getFullLabelText();
  359.          if(_loc1_.length > _loc3_.length)
  360.          {
  361.             return _loc1_;
  362.          }
  363.          return _loc3_;
  364.       }
  365.       
  366.       [Bindable("change")]
  367.       public function get value() : Number
  368.       {
  369.          return _value;
  370.       }
  371.       
  372.       public function set indeterminate(param1:Boolean) : void
  373.       {
  374.          _indeterminate = param1;
  375.          indeterminateChanged = true;
  376.          invalidateProperties();
  377.          invalidateDisplayList();
  378.          dispatchEvent(new Event("indeterminateChanged"));
  379.       }
  380.       
  381.       private function createBar() : void
  382.       {
  383.          if(mx_internal::_determinateBar)
  384.          {
  385.             mx_internal::_bar.removeChild(DisplayObject(mx_internal::_determinateBar));
  386.             _determinateBar = null;
  387.          }
  388.          var _loc1_:Class = getStyle("barSkin");
  389.          if(_loc1_)
  390.          {
  391.             _determinateBar = new _loc1_();
  392.             if(mx_internal::_determinateBar is ISimpleStyleClient)
  393.             {
  394.                ISimpleStyleClient(mx_internal::_determinateBar).styleName = this;
  395.             }
  396.             mx_internal::_bar.addChild(DisplayObject(mx_internal::_determinateBar));
  397.          }
  398.       }
  399.       
  400.       private function createIndeterminateBar() : void
  401.       {
  402.          if(mx_internal::_indeterminateBar)
  403.          {
  404.             mx_internal::_bar.removeChild(DisplayObject(mx_internal::_indeterminateBar));
  405.             _indeterminateBar = null;
  406.          }
  407.          var _loc1_:Class = getStyle("indeterminateSkin");
  408.          if(_loc1_)
  409.          {
  410.             _indeterminateBar = new _loc1_();
  411.             if(mx_internal::_indeterminateBar is ISimpleStyleClient)
  412.             {
  413.                ISimpleStyleClient(mx_internal::_indeterminateBar).styleName = this;
  414.             }
  415.             mx_internal::_indeterminateBar.visible = false;
  416.             mx_internal::_bar.addChild(DisplayObject(mx_internal::_indeterminateBar));
  417.          }
  418.       }
  419.       
  420.       [Bindable("directionChanged")]
  421.       public function get direction() : String
  422.       {
  423.          return _direction;
  424.       }
  425.       
  426.       private function updatePolledHandler(param1:Event) : void
  427.       {
  428.          var _loc2_:Object = null;
  429.          var _loc3_:Number = NaN;
  430.          var _loc4_:Number = NaN;
  431.          if(_source)
  432.          {
  433.             _loc2_ = _source;
  434.             _loc3_ = _loc2_.bytesLoaded;
  435.             _loc4_ = _loc2_.bytesTotal;
  436.             if(!isNaN(_loc3_) && !isNaN(_loc4_))
  437.             {
  438.                _setProgress(_loc3_,_loc4_);
  439.                if(percentComplete >= 100 && _value > 0)
  440.                {
  441.                   pollTimer.reset();
  442.                }
  443.             }
  444.          }
  445.       }
  446.       
  447.       private function updateIndeterminateHandler(param1:Event) : void
  448.       {
  449.          if(mx_internal::_indeterminateBar.x < 1)
  450.          {
  451.             mx_internal::_indeterminateBar.x += 1;
  452.          }
  453.          else
  454.          {
  455.             mx_internal::_indeterminateBar.x = -(getStyle("indeterminateMoveInterval") - 2);
  456.          }
  457.       }
  458.       
  459.       public function set labelPlacement(param1:String) : void
  460.       {
  461.          if(param1 != _labelPlacement)
  462.          {
  463.             _labelPlacement = param1;
  464.          }
  465.          invalidateSize();
  466.          invalidateDisplayList();
  467.          dispatchEvent(new Event("labelPlacementChanged"));
  468.       }
  469.       
  470.       [Bindable("modeChanged")]
  471.       public function get mode() : String
  472.       {
  473.          return _mode;
  474.       }
  475.       
  476.       [Bindable("progress")]
  477.       public function get percentComplete() : Number
  478.       {
  479.          if(_value < _minimum || _maximum < _minimum)
  480.          {
  481.             return 0;
  482.          }
  483.          if(_maximum - _minimum == 0)
  484.          {
  485.             return 0;
  486.          }
  487.          var _loc1_:Number = 100 * (_value - _minimum) / (_maximum - _minimum);
  488.          if(isNaN(_loc1_) || _loc1_ < 0)
  489.          {
  490.             return 0;
  491.          }
  492.          if(_loc1_ > 100)
  493.          {
  494.             return 100;
  495.          }
  496.          return _loc1_;
  497.       }
  498.       
  499.       public function setProgress(param1:Number, param2:Number) : void
  500.       {
  501.          if(_mode == ProgressBarMode.MANUAL)
  502.          {
  503.             _setProgress(param1,param2);
  504.          }
  505.       }
  506.       
  507.       private function createTrack() : void
  508.       {
  509.          if(mx_internal::_track)
  510.          {
  511.             mx_internal::_content.removeChild(DisplayObject(mx_internal::_track));
  512.             _track = null;
  513.          }
  514.          var _loc1_:Class = getStyle("trackSkin");
  515.          if(_loc1_)
  516.          {
  517.             _track = new _loc1_();
  518.             if(mx_internal::_track is ISimpleStyleClient)
  519.             {
  520.                ISimpleStyleClient(mx_internal::_track).styleName = this;
  521.             }
  522.             mx_internal::_content.addChildAt(DisplayObject(mx_internal::_track),0);
  523.          }
  524.       }
  525.       
  526.       [Bindable("indeterminateChanged")]
  527.       public function get indeterminate() : Boolean
  528.       {
  529.          return _indeterminate;
  530.       }
  531.       
  532.       private function startPlayingIndeterminate() : void
  533.       {
  534.          if(!indeterminatePlaying)
  535.          {
  536.             indeterminatePlaying = true;
  537.             pollTimer.addEventListener(TimerEvent.TIMER,updateIndeterminateHandler,false,0,true);
  538.             pollTimer.start();
  539.          }
  540.       }
  541.       
  542.       override public function styleChanged(param1:String) : void
  543.       {
  544.          var _loc2_:Boolean = false;
  545.          super.styleChanged(param1);
  546.          if(param1 == null || param1 == "styleName")
  547.          {
  548.             barSkinChanged = trackSkinChanged = indeterminateSkinChanged = true;
  549.             _loc2_ = true;
  550.          }
  551.          else if(param1 == "barSkin")
  552.          {
  553.             barSkinChanged = true;
  554.             _loc2_ = true;
  555.          }
  556.          else if(param1 == "trackSkin")
  557.          {
  558.             trackSkinChanged = true;
  559.             _loc2_ = true;
  560.          }
  561.          else if(param1 == "indeterminateSkin")
  562.          {
  563.             indeterminateSkinChanged = true;
  564.             _loc2_ = true;
  565.          }
  566.          if(_loc2_)
  567.          {
  568.             invalidateProperties();
  569.             invalidateSize();
  570.             invalidateDisplayList();
  571.          }
  572.       }
  573.       
  574.       private function getFullLabelText() : String
  575.       {
  576.          var _loc1_:Number = Math.max(_value,0);
  577.          var _loc2_:Number = Math.max(_maximum,0);
  578.          var _loc3_:String = label;
  579.          if(_loc3_)
  580.          {
  581.             if(_indeterminate)
  582.             {
  583.                _loc3_ = _loc3_.replace("%1",String(Math.floor(_loc1_ / _conversion)));
  584.                _loc3_ = _loc3_.replace("%2","??");
  585.                _loc3_ = _loc3_.replace("%3","");
  586.                _loc3_ = _loc3_.replace("%%","");
  587.             }
  588.             else
  589.             {
  590.                _loc3_ = _loc3_.replace("%1",String(Math.floor(_loc1_ / _conversion)));
  591.                _loc3_ = _loc3_.replace("%2",String(Math.floor(_loc2_ / _conversion)));
  592.                _loc3_ = _loc3_.replace("%3",String(Math.floor(percentComplete)));
  593.                _loc3_ = _loc3_.replace("%%","%");
  594.             }
  595.          }
  596.          return _loc3_;
  597.       }
  598.       
  599.       override protected function commitProperties() : void
  600.       {
  601.          var index:int = 0;
  602.          super.commitProperties();
  603.          if(hasFontContextChanged() && mx_internal::_labelField != null)
  604.          {
  605.             index = getChildIndex(DisplayObject(mx_internal::_labelField));
  606.             removeChild(DisplayObject(mx_internal::_labelField));
  607.             _labelField = IUITextField(createInFontContext(UITextField));
  608.             mx_internal::_labelField.styleName = this;
  609.             addChildAt(DisplayObject(mx_internal::_labelField),index);
  610.          }
  611.          if(trackSkinChanged)
  612.          {
  613.             trackSkinChanged = false;
  614.             createTrack();
  615.          }
  616.          if(barSkinChanged)
  617.          {
  618.             barSkinChanged = false;
  619.             createBar();
  620.          }
  621.          if(indeterminateSkinChanged)
  622.          {
  623.             indeterminateSkinChanged = false;
  624.             createIndeterminateBar();
  625.          }
  626.          if(stringSourceChanged)
  627.          {
  628.             stringSourceChanged = false;
  629.             try
  630.             {
  631.                _source = document[_stringSource];
  632.             }
  633.             catch(e:Error)
  634.             {
  635.             }
  636.          }
  637.          if(sourceChanged)
  638.          {
  639.             sourceChanged = false;
  640.             dispatchEvent(new Event("sourceChanged"));
  641.          }
  642.          if(modeChanged)
  643.          {
  644.             modeChanged = false;
  645.             if(_source)
  646.             {
  647.                if(_mode == ProgressBarMode.EVENT)
  648.                {
  649.                   if(_source is IEventDispatcher)
  650.                   {
  651.                      _source.addEventListener(ProgressEvent.PROGRESS,progressHandler);
  652.                      _source.addEventListener(Event.COMPLETE,completeHandler);
  653.                   }
  654.                   else
  655.                   {
  656.                      _source = null;
  657.                   }
  658.                }
  659.                else
  660.                {
  661.                   _source.removeEventListener(ProgressEvent.PROGRESS,progressHandler);
  662.                   _source.removeEventListener(Event.COMPLETE,completeHandler);
  663.                }
  664.             }
  665.             if(_mode == ProgressBarMode.POLLED)
  666.             {
  667.                pollTimer.addEventListener(TimerEvent.TIMER,updatePolledHandler,false,0,true);
  668.                pollTimer.start();
  669.             }
  670.             else if(stopPolledMode)
  671.             {
  672.                stopPolledMode = false;
  673.                pollTimer.removeEventListener(TimerEvent.TIMER,updatePolledHandler);
  674.                pollTimer.reset();
  675.             }
  676.             dispatchEvent(new Event("modeChanged"));
  677.          }
  678.       }
  679.       
  680.       override protected function resourcesChanged() : void
  681.       {
  682.          super.resourcesChanged();
  683.          label = labelOverride;
  684.       }
  685.       
  686.       public function set fontContext(param1:IFlexModuleFactory) : void
  687.       {
  688.          this.moduleFactory = param1;
  689.       }
  690.       
  691.       override public function set visible(param1:Boolean) : void
  692.       {
  693.          super.visible = param1;
  694.          visibleChanged = true;
  695.          invalidateDisplayList();
  696.       }
  697.       
  698.       public function set label(param1:String) : void
  699.       {
  700.          labelOverride = param1;
  701.          _label = param1 != null ? param1 : resourceManager.getString("controls","label");
  702.          invalidateDisplayList();
  703.          dispatchEvent(new Event("labelChanged"));
  704.       }
  705.       
  706.       override protected function childrenCreated() : void
  707.       {
  708.          super.childrenCreated();
  709.          trackSkinChanged = true;
  710.          barSkinChanged = true;
  711.          indeterminateSkinChanged = true;
  712.       }
  713.       
  714.       private function layoutContent(param1:Number, param2:Number) : void
  715.       {
  716.          mx_internal::_track.move(0,0);
  717.          mx_internal::_track.setActualSize(param1,param2);
  718.          mx_internal::_bar.move(0,0);
  719.          mx_internal::_determinateBar.move(0,0);
  720.          mx_internal::_indeterminateBar.setActualSize(param1 + getStyle("indeterminateMoveInterval"),param2);
  721.       }
  722.       
  723.       private function _setProgress(param1:Number, param2:Number) : void
  724.       {
  725.          var _loc3_:ProgressEvent = null;
  726.          if(enabled && !isNaN(param1) && !isNaN(param2))
  727.          {
  728.             _value = param1;
  729.             _maximum = param2;
  730.             dispatchEvent(new Event(Event.CHANGE));
  731.             _loc3_ = new ProgressEvent(ProgressEvent.PROGRESS);
  732.             _loc3_.bytesLoaded = param1;
  733.             _loc3_.bytesTotal = param2;
  734.             dispatchEvent(_loc3_);
  735.             if(_indeterminate)
  736.             {
  737.                startPlayingIndeterminate();
  738.             }
  739.             if(_value == _maximum && _value > 0)
  740.             {
  741.                if(_indeterminate)
  742.                {
  743.                   stopPlayingIndeterminate();
  744.                }
  745.                if(mode != ProgressBarMode.EVENT)
  746.                {
  747.                   dispatchEvent(new Event(Event.COMPLETE));
  748.                }
  749.             }
  750.             invalidateDisplayList();
  751.          }
  752.       }
  753.       
  754.       [Bindable("labelChanged")]
  755.       public function get label() : String
  756.       {
  757.          return _label;
  758.       }
  759.       
  760.       override protected function updateDisplayList(param1:Number, param2:Number) : void
  761.       {
  762.          var _loc16_:Number = NaN;
  763.          var _loc17_:Graphics = null;
  764.          var _loc18_:Number = NaN;
  765.          super.updateDisplayList(param1,param2);
  766.          var _loc3_:Number = getStyle("horizontalGap");
  767.          var _loc4_:Number = getStyle("verticalGap");
  768.          var _loc5_:Number = getStyle("paddingLeft");
  769.          var _loc6_:Number = getStyle("paddingRight");
  770.          var _loc7_:Number = getStyle("paddingTop");
  771.          var _loc8_:Number = getStyle("paddingBottom");
  772.          var _loc9_:Number = _loc5_;
  773.          var _loc10_:Number = _loc7_;
  774.          var _loc11_:Number = getStyle("labelWidth");
  775.          var _loc12_:Number = getStyle("trackHeight");
  776.          _loc12_ = !!isNaN(_loc12_) ? Number(mx_internal::_track.measuredHeight) : Number(_loc12_);
  777.          var _loc13_:TextLineMetrics = measureText(predictLabelText());
  778.          var _loc14_:Number = !!isNaN(_loc11_) ? Number(_loc13_.width + UITextField.TEXT_WIDTH_PADDING) : Number(_loc11_);
  779.          var _loc15_:Number = _loc13_.height + UITextField.TEXT_HEIGHT_PADDING;
  780.          switch(labelPlacement)
  781.          {
  782.             case ProgressBarLabelPlacement.TOP:
  783.                mx_internal::_labelField.move(_loc9_,_loc10_);
  784.                mx_internal::_labelField.setActualSize(_loc14_,_loc15_);
  785.                mx_internal::_content.move(_loc9_,_loc10_ + _loc15_ + _loc4_);
  786.                layoutContent(param1 - _loc9_ - _loc6_,_loc12_);
  787.                break;
  788.             case ProgressBarLabelPlacement.RIGHT:
  789.                _loc16_ = param1 - _loc9_ - _loc6_ - _loc14_ - _loc3_;
  790.                mx_internal::_labelField.move(_loc9_ + _loc16_ + _loc3_,(param2 - _loc15_) / 2);
  791.                mx_internal::_labelField.setActualSize(_loc14_,_loc15_);
  792.                mx_internal::_content.move(_loc9_,_loc10_ + (_loc15_ - _loc12_) / 2);
  793.                layoutContent(_loc16_,_loc12_);
  794.                break;
  795.             case ProgressBarLabelPlacement.LEFT:
  796.                mx_internal::_labelField.move(_loc9_,_loc10_ + (param2 - _loc15_) / 2);
  797.                mx_internal::_labelField.setActualSize(_loc14_,_loc15_);
  798.                mx_internal::_content.move(_loc9_ + _loc14_ + _loc3_,_loc10_ + (_loc15_ - _loc12_) / 2);
  799.                layoutContent(param1 - _loc9_ - _loc14_ - _loc4_ - _loc6_,_loc12_);
  800.                break;
  801.             case ProgressBarLabelPlacement.CENTER:
  802.                mx_internal::_labelField.move((param1 - _loc14_) / 2,(param2 - _loc15_) / 2);
  803.                mx_internal::_labelField.setActualSize(_loc14_,_loc15_);
  804.                mx_internal::_content.move(_loc9_,_loc10_);
  805.                layoutContent(param1 - _loc6_,param2 - _loc8_);
  806.                break;
  807.             default:
  808.                mx_internal::_labelField.move(_loc9_,_loc10_ + _loc12_ + _loc4_);
  809.                mx_internal::_labelField.setActualSize(_loc14_,_loc15_);
  810.                mx_internal::_content.move(_loc9_,_loc10_);
  811.                layoutContent(param1 - _loc9_ - _loc6_,_loc12_);
  812.          }
  813.          if(mx_internal::_barMask)
  814.          {
  815.             mx_internal::_barMask.move(0,0);
  816.             if(FlexVersion.compatibilityVersion >= FlexVersion.VERSION_3_0)
  817.             {
  818.                mx_internal::_barMask.setActualSize(mx_internal::_track.width,mx_internal::_track.height);
  819.             }
  820.             else
  821.             {
  822.                (_loc17_ = UIComponent(mx_internal::_barMask).graphics).clear();
  823.                _loc17_.beginFill(16776960);
  824.                _loc17_.drawRect(1,1,mx_internal::_track.width - 2,mx_internal::_track.height - 2);
  825.                _loc17_.endFill();
  826.             }
  827.          }
  828.          mx_internal::_labelField.text = getFullLabelText();
  829.          mx_internal::_indeterminateBar.visible = _indeterminate;
  830.          if(indeterminateChanged || visibleChanged)
  831.          {
  832.             indeterminateChanged = false;
  833.             visibleChanged = false;
  834.             mx_internal::_indeterminateBar.visible = _indeterminate;
  835.             if(_indeterminate && _source == null && _mode == ProgressBarMode.EVENT && visible)
  836.             {
  837.                startPlayingIndeterminate();
  838.             }
  839.             else
  840.             {
  841.                stopPlayingIndeterminate();
  842.             }
  843.          }
  844.          if(_indeterminate)
  845.          {
  846.             mx_internal::_determinateBar.setActualSize(mx_internal::_track.width,mx_internal::_track.height);
  847.          }
  848.          else
  849.          {
  850.             _loc18_ = Math.max(0,mx_internal::_track.width * percentComplete / 100);
  851.             mx_internal::_determinateBar.setActualSize(_loc18_,mx_internal::_track.height);
  852.             mx_internal::_determinateBar.x = direction == ProgressBarDirection.RIGHT ? Number(0) : Number(mx_internal::_track.width - _loc18_);
  853.          }
  854.       }
  855.       
  856.       public function set direction(param1:String) : void
  857.       {
  858.          if(param1 == ProgressBarDirection.LEFT || param1 == ProgressBarDirection.RIGHT)
  859.          {
  860.             _direction = param1;
  861.          }
  862.          invalidateDisplayList();
  863.          dispatchEvent(new Event("directionChanged"));
  864.       }
  865.    }
  866. }
  867.